//
//  SEGOrderActionModel.m
//  Uhomebk
//
//  Created by mac on 2017/10/9.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "SEGOrderActionModel.h"

@implementation SEGOrderActionModel
- (instancetype)initWithDictionary:(NSDictionary*)dictionary
{
    self = [super init];
    if (self) {
        _actionCode = @"";
        _actionName = @"";
        _formList = [[NSArray alloc] init];
        [self setValuesForKeysWithDictionary:dictionary];
        
        self.mDictionary = [[NSMutableDictionary alloc] initWithDictionary:dictionary];
        
        
    }
    return self;
}

+ (instancetype)initWithDictionary:(NSDictionary*)dictionary
{
    return [[self alloc] initWithDictionary:dictionary];
}

-(void)setActionCode:(NSString *)actionCode
{
    _actionCode= [SEGUtils ValueToString:actionCode];
}

-(void)setActionName:(NSString *)actionName
{
    _actionName = [SEGUtils ValueToString:actionName];
}

- (void)setValue:(id)value forUndefinedKey:(NSString*)key
{//注意此方法
    
}


-(void)setValue:(id)value forKey:(NSString *)key
{
    if ([key isEqualToString:@"formList"]) {
        
        __block NSMutableArray* _arrM = [NSMutableArray array];
        
        [value enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            if([obj isKindOfClass:[SEGTemplateModel class]]){
                [_arrM addObject:obj];
            }else{
                SEGTemplateModel* model = [SEGTemplateModel initWithDictionary:obj];
                [_arrM addObject:model];
            }
        }];
        
        _formList = _arrM;
        return;
    }
      [super setValue:value forKey:key];
}


@end
